package com.migrator.ui;

import java.awt.BorderLayout;
import java.awt.GridLayout;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;

public class ConnectionPanel extends JPanel {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	Integer preferredSize = 10 ;
	private JTextField hostField = new JTextField(preferredSize) ;
	private JTextField portField = new JTextField(preferredSize) ;
	private JTextField usernameField = new JTextField(preferredSize) ;
	private JPasswordField passwordField = new JPasswordField(preferredSize) ;
	private JTextField databaseField = new JTextField(preferredSize) ;
	
	public ConnectionPanel(){
		 
		
		JPanel panelLabel = new JPanel(new GridLayout(4,1,5,5)) ;
		
		panelLabel.add(new JLabel("Host : ")) ;
		panelLabel.add(new JLabel("Port : ")) ;
		panelLabel.add(new JLabel("Username : ")) ;
		panelLabel.add(new JLabel("Password : ")) ;
	
		JPanel panelField = new JPanel(new GridLayout(4, 1,5,5)) ;
		panelField.add(this.hostField);
		panelField.add(this.portField);
		panelField.add(this.usernameField);
		panelField.add(this.passwordField);

		
		setLayout(new BorderLayout(5, 2 ));
		add(panelLabel,BorderLayout.WEST);
		add(panelField,BorderLayout.CENTER);
		
		
	}
	
	public String getHost(){
		return this.hostField.getText() ;
	}
	
	public String getPort(){
		return this.portField.getText() ;
	}
	
	public String getUsername(){
		return this.usernameField.getText() ;
	}
	
	public String getPassword(){
		return new String(this.passwordField.getPassword());
	}
	
	public String getDatabase(){
		return this.databaseField.getText() ;
	}

}
